package com.keehin.migrate;

import java.sql.SQLException;

import com.keehin.Database;

public class MigrateAccount {
	protected static Database srcDB;
	protected static Database descDB;

	public static void main(String[] args) {
		try {
			// srcDB = new Database(new com.mysql.jdbc.Driver(), "jdbc:mysql://"
			// + args[0] + "?characterEncoding=tis620", args[2], args[3]);
			// if (srcDB != null)
			// System.out.println(srcDB + " OK");
			descDB = new Database(new com.mysql.jdbc.Driver(), "jdbc:mysql://"
					+ args[1] + "?characterEncoding=tis620", args[2], args[3]);
			if (descDB != null)
				System.out.println(descDB + " OK");
		} catch (SQLException e) {
			e.printStackTrace();
		}

//		descDB.executeUpdate("delete from account");
//		descDB.executeUpdate("insert into windmill.account(comCode,accCode, descript) select '"
//				+ args[4] + "',ledgerAccount, Description from migrate.ledacc");

		descDB.executeUpdate("delete from paymeth");
		descDB.executeUpdate("insert into windmill.paymeth select '"
				+ args[4]
				+ "',pay.PayMethCode, pay.PaymentMethod, pay.PaymentHandlingType, acc.LedgerAccount "
				+ "from migrate.paymeth pay, migrate.methacc acc where acc.CompanyNumber = 1 and pay.PayMethCode=acc.PaymentMethod");
	}

	public static void printSymbol(int i) {
		if (i % 500 == 0) {
			System.out.print("#");
			if (i % 100000 == 0)
				System.out.printf("%,10d\n", i);
			else if (i % 50000 == 0)
				System.out.println();
		}
	}
}
